home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / MacHacksBug / Python 1.5.2c1 / Lib / lib-tk / FixTk.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-06-23  |  2.3 KB  |  59 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. '''Utility which tries to locate the Tcl/Tk 8.0 DLLs on Windows.
  5.  
  6. This is a no-op on other platforms.
  7. '''
  8. NO_TCL_MESSAGE = "WHOOPS!  I can't find a Tcl/Tk 8.0 installation anywhere.\nPlease make sure that Tcl.Tk 8.0 is installed and that the PATH\nenvironment variable is set to include the Tcl/bin directory\n(or wherever TK80.DLL and TCL80.DLL are installed).\nIf you don't know how to fix this, consider searching the Python FAQ\nfor the error you get; post to the comp.lang.python if all else fails.\nRead the source file FixTk.py for details.\n"
  9. NO_TKINTER_MESSAGE = "WHOOPS!  Even though I think I have found a Tcl/Tk 8.0 installation,\nI can't seem to import the _tkinter extension module.\nI get the following exception:\n    ImportError: %s\nIf you don't know how to fix this, consider searching the Python FAQ\nfor the error you get; post to the comp.lang.python if all else fails.\nRead the source file FixTk.py for details.\n"
  10. import sys
  11. if sys.platform == 'win32':
  12.     
  13.     try:
  14.         import _tkinter
  15.     except ImportError:
  16.         import os
  17.         
  18.         try:
  19.             path = os.environ['PATH']
  20.         except KeyError:
  21.             path = ''
  22.  
  23.         python_exe = sys.executable
  24.         python_dir = os.path.dirname(python_exe)
  25.         program_files = os.path.dirname(python_dir)
  26.         
  27.         def tclcheck(dir):
  28.             for dll in ('tcl80.dll', 'tk80.dll', 'tclpip80.dll'):
  29.                 pass
  30.             
  31.             return 1
  32.  
  33.         for tcldir in [
  34.             program_files,
  35.             '\\Program files',
  36.             '\\',
  37.             'C:\\Program Files',
  38.             'D:\\Program Files']:
  39.             tcldir = os.path.join(tcldir, 'Tcl', 'bin')
  40.         else:
  41.             tcldir = None
  42.         if not tcldir:
  43.             sys.stderr.write(NO_TCL_MESSAGE)
  44.         elif path and path[-1] != os.pathsep:
  45.             path = path + os.pathsep
  46.         
  47.         path = path + tcldir
  48.         os.environ['PATH'] = path
  49.         os.putenv('PATH', path)
  50.         
  51.         try:
  52.             import _tkinter
  53.         except ImportError:
  54.             message = None
  55.             sys.stderr.write(NO_TKINTER_MESSAGE % str(message))
  56.  
  57.  
  58.  
  59.